package com.lmaos.basetools.select;

import java.math.BigDecimal;

public class Select {
	 
	private double min;
	private double max;
	
	private Object value;
	
	
	
	public Select(double min, double max, Object value) {
		super();
		this.min = min;
		this.max = max;
		this.value = value;
	}
	public double getMax() {
		return max;
	}
	public double getMin() {
		return min;
	}
	public <T>T getObject(){
		if(value == null){
			return null;
		}
		return (T) value;
	}
	public int getInt(){
		Number key = getNumber(value);
		return key.intValue();
	}
	public long getLong(){
		Number key = getNumber(value);
		return key.longValue();
	}
	public float getFloat(){
		Number key = getNumber(value);
		return key.floatValue();
	}
	public double getDouble(){
		Number key = getNumber(value);
		return key.doubleValue();
	}
	public short getShort(){
		Number key = getNumber(value);
		return key.shortValue();
	}
	public byte getByte(){
		Number key = getNumber(value);
		return key.byteValue();
	}
	public String getString(){
		return getObject();
	}
	public Number getNumber(Object value){
		if(value==null){
			return 0;
		}
		if(value instanceof Number){
			return (Number) value;
		}
		try{
			return new BigDecimal(String.valueOf(value));
		}catch(Exception e){
			return 0;
		}
	}
}
